#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
using namespace std;

#include "STL_Priority_Queue.h"

//int findKthLargest(vector<int>& nums, int k) {
//    priority_queue<int, vector<int>, greater<int>> pq;
//    for (size_t i = 0; i < k; i++)
//    {
//        pq.push(nums[i]);
//    }
//    for (size_t i = k; i < nums.size(); i++)
//    {
//        if (pq.top() < nums[i])
//        {
//            pq.pop();
//            pq.push(nums[i]);
//        }
//    }
//    return pq.top();
//}
//
//int main()
//{
//
//    vector<int> nums;
//    nums.push_back(1);
//    nums.push_back(2);
//    nums.push_back(3);
//    nums.push_back(4);
//    nums.push_back(5);
//    nums.push_back(10);
//    nums.push_back(8);
//    nums.push_back(7);
//    nums.push_back(20);
//    findKthLargest(nums, 7);
//    return 0;
//}

//int main()
//{
//	/*vector<int> cont = { 1, 2, 3, 4, 5 };
//	vector<int>::iterator iter, tempIt;*/
//
//	/*list<int> cont = { 1, 2, 3, 4, 5 };
//	list<int>::iterator iter, tempIt;*/
//
//	deque<int> cont = { 1, 2, 3, 4, 5 };
//	deque<int>::iterator iter, tempIt;
//
//	for (iter = cont.begin(); iter != cont.end();)
//	{
//		tempIt = iter;
//		++iter;
//		cont.erase(tempIt);
//	}
//}

void test_priority_queue1()
{
	
	cout << "大堆：";
	vector<int> v;
	v.push_back(6);
	v.push_back(7);
	v.push_back(1);
	v.push_back(9);
	v.push_back(54);
	v.push_back(31);
	v.push_back(46);
	priority_queue<int, vector<int>, less<int>> pq(v.begin(), v.end());
	
	pq.size();
	
	while (!pq.empty())
	{
		cout << pq.top() << " ";
		pq.pop();
	}
	cout << endl;
}

void test_priority_queue2()
{
	cout << "小堆：";
	vector<int> v;
	v.push_back(6);
	v.push_back(7);
	v.push_back(1);
	v.push_back(9);
	v.push_back(54);
	v.push_back(31);
	v.push_back(46);
	priority_queue<int, vector<int>, greater<int>> pq(v.begin(), v.end());

	pq.size();

	while (!pq.empty())
	{
		cout << pq.top() << " ";
		pq.pop();
	}
	cout << endl;
}

int main()
{
	test_priority_queue1();
	test_priority_queue2();
	return 0;
}